package com.example.chatweb.constant;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.example.chatweb.entity.Token;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ApiConstant {
    public static final String ERNIE_BOT_TURBO_INSTANT = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/eb-instant?access_token=";

    private static final String appKey = "3ZgxP8EiqUeQDBWhI5B2Wq0n";

    private static final String secretKey = "4XnHyu1MCEqXP84MNNiV2OiWl8REko32";

    public static String getToken() {
        String url = "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=" + ApiConstant.appKey + "&client_secret=" + ApiConstant.secretKey;
        String s = HttpUtil.get(url);
        Token bean = JSON.parseObject(s, Token.class);
        return bean.getAccess_token();
    }
}
